namespace ai_library
{
	public class StateFactoryException : System.Exception
	{
		protected string message;
		public StateFactoryException(string message) { this.message = message; }
		public override string Message { get { return message; } }
		public override string ToString() { return "State Factory Exception: " + message; }
	}

	public static class StateFactory<T> where T : IEntity, IEntityStateMachine<T>
	{
		public static IState<T> Get(StateTypes stateType)
		{
			IState<T> retState = null;

			switch (stateType)
			{
			case StateTypes.GlobalMessagingState:
				retState = GlobalMessagingState<T>.Instance;
				break;

			case StateTypes.IdleState:
				retState = IdleState<T>.Instance;
				break;

			case StateTypes.WanderState:
				retState = WanderState<T>.Instance;
				break;
			}

			if (retState == null)
				throw new StateFactoryException("StateType " + stateType + " not defined in factory");

			return retState;
		}
	}
}

